package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmCartoonCommentMapper;
import cn.mcartoon.pojo.MmCartoonComment;
import cn.mcartoon.service.MmCartoonCommentService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmCartoonCommentServiceImpl implements MmCartoonCommentService {

    @Autowired
    private MmCartoonCommentMapper mmCartoonCommentMapper;

    public MmCartoonComment getMmCartoonCommentById(Long id){
        return mmCartoonCommentMapper.getMmCartoonCommentById(id);
    }

    public List<MmCartoonComment>	getMmCartoonCommentListByMap(Map<String,Object> param){
        return mmCartoonCommentMapper.getMmCartoonCommentListByMap(param);
    }

    public Integer getMmCartoonCommentCountByMap(Map<String,Object> param){
        return mmCartoonCommentMapper.getMmCartoonCommentCountByMap(param);
    }

    public Integer insertMmCartoonComment(MmCartoonComment mmCartoonComment){
            return mmCartoonCommentMapper.insertMmCartoonComment(mmCartoonComment);
    }

    public Integer updateMmCartoonComment(MmCartoonComment mmCartoonComment){
        return mmCartoonCommentMapper.updateMmCartoonComment(mmCartoonComment);
    }

    public Integer deleteMmCartoonCommentById(Long id){
        return mmCartoonCommentMapper.deleteMmCartoonCommentById(id);
    }

    public Integer batchDeleteMmCartoonComment(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmCartoonCommentMapper.batchDeleteMmCartoonComment(param);
    }

    public Page<MmCartoonComment> queryMmCartoonCommentPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmCartoonCommentMapper.getMmCartoonCommentCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmCartoonComment> mmCartoonCommentList = mmCartoonCommentMapper.getMmCartoonCommentListByMap(param);
        page.setList(mmCartoonCommentList);
        return page;
     }


}
